/*
 * Copyright 2012 Daniel Kurka
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.googlecode.mgwt.expenses.client.activities.el;

import com.google.gwt.core.client.GWT;
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.googlecode.mgwt.expenses.client.misc.I18N;
import com.googlecode.mgwt.ui.client.widget.celllist.Cell;

public class ExpenseListMobileCell implements Cell<ExpenseListDTO> {

	private static Template TEMPLATE = GWT.create(Template.class);

	public interface Template extends SafeHtmlTemplates {
		@SafeHtmlTemplates.Template("<div><div style='font-size: 14pt; font-weight: bold;'>{0}</div> <div style='font-size: 8pt; font-weight: lighter;'>Sum: {2}</div> <div style='font-size: 8pt; font-weight: lighter;'>Date: {1} </div></div>")
		SafeHtml content(String title, String date, String amount);

	}

	@Override
	public void render(SafeHtmlBuilder safeHtmlBuilder, ExpenseListDTO model) {

		SafeHtml content = TEMPLATE.content(model.getTitle(), I18N.DATE_FORMAT.format(model.getDate()), I18N.NUMBER_FORMAT.format(model.getAmount()));

		safeHtmlBuilder.append(content);

	}

	@Override
	public boolean canBeSelected(ExpenseListDTO model) {
		return true;
	}

}
